package com.ruoyi.environment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.environment.domain.OpmEnvCompyAssess;
import com.ruoyi.environment.service.IOpmEnvCompyAssessService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 企业环评资料Controller
 *
 * @author zmc
 * @date 2021-07-23
 */
@Api(tags = " 企业环评资料")
@RestController
@RequestMapping("/opmEnvCompyAssess")
public class OpmEnvCompyAssessController extends BaseController {
    @Autowired
    private IOpmEnvCompyAssessService opmEnvCompyAssessService;

    /**
     * 查询企业环评资料列表
     */
    @ApiOperation(value="查询企业环评资料列表", notes="查询企业环评资料列表")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:list")
    @GetMapping("/list")
    public TableDataInfo list(OpmEnvCompyAssess opmEnvCompyAssess) {
        startPage();
        List<OpmEnvCompyAssess> list = opmEnvCompyAssessService.selectOpmEnvCompyAssessList(opmEnvCompyAssess);
        return getDataTable(list);
    }

    /**
     * 导出企业环评资料列表
     */
    @ApiOperation(value="导出企业环评资料列表", notes="导出企业环评资料列表")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:export")
    @Log(title = "企业环评资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OpmEnvCompyAssess opmEnvCompyAssess) throws IOException {
        List<OpmEnvCompyAssess> list = opmEnvCompyAssessService.selectOpmEnvCompyAssessList(opmEnvCompyAssess);
        ExcelUtil<OpmEnvCompyAssess> util = new ExcelUtil<OpmEnvCompyAssess>(OpmEnvCompyAssess.class);
        util.exportExcel(response, list, "企业环评资料数据");
    }
    /**
     * 获取企业环评资料详细信息
     */
    @ApiOperation(value="获取企业环评资料详细信息", notes="获取企业环评资料详细信息")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(opmEnvCompyAssessService.selectOpmEnvCompyAssessById(id));
    }

    /**
     * 新增企业环评资料
     */
    @ApiOperation(value="新增企业环评资料", notes="新增企业环评资料")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:add")
    @Log(title = "企业环评资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpmEnvCompyAssess opmEnvCompyAssess) {
        return toAjax(opmEnvCompyAssessService.insertOpmEnvCompyAssess(opmEnvCompyAssess));
    }

    /**
     * 修改企业环评资料
     */
    @ApiOperation(value="修改企业环评资料", notes="修改企业环评资料")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:edit")
    @Log(title = "企业环评资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpmEnvCompyAssess opmEnvCompyAssess) {
        return toAjax(opmEnvCompyAssessService.updateOpmEnvCompyAssess(opmEnvCompyAssess));
    }

    /**
     * 删除企业环评资料
     */
    @ApiOperation(value="删除企业环评资料", notes="删除企业环评资料")
    @ApiImplicitParam(name = "ids", value = "企业环评资料ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "environment:opmEnvCompyAssess:remove")
    @Log(title = "企业环评资料", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(opmEnvCompyAssessService.deleteOpmEnvCompyAssessByIds(ids));
    }
}
